Ext.define('Login.controller.user.LoginController', {
	extend : 'Ext.app.Controller',

	views : [ 'user.LoginView' ],

	refs : [ {
		ref : 'appLogin',
		selector : 'appLogin',
		autoCreate : true,
		xtype : 'applogin'
	} ],

	init : function() {
		this.control({
			'applogin #submit' : {
				click : this.onSubmitLogin
			},
			'applogin textfield' : {
				keypress : this.onSubmitLoginEnter
			}
		});
	},

	onSubmitLogin : function(button, e, eOpts) {
		var form = button.up('form');
		form.submit();
	},

	onSubmitLoginEnter : function(textfield, e, eOpts) {		
		if (e.keyCode === 13) {
			var form = textfield.up('form');
			this.onSubmitLogin(form.down('button'));
		}
	}
});